﻿using Stardust.Client;
using Stardust.Common.Utils;
using Stardust.ConfigCenterWeb.Code;
using Stardust.ConfigCenterWeb.Code.Services;
using System.Web.Mvc;
using System.Web.Routing;

namespace Stardust.ConfigCenterWeb
{
    public class MvcApplication : System.Web.HttpApplication
    {
        MutilElapseTimer timer;

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            timer = new MutilElapseTimer();
            //run jobs
            //监测是否是活的
            timer.AddJob(CCConfig.CheckAliveIntervalSeconds, ServerNodeService.Instance.CheckAliveJob);
            //检测断开的节点
            timer.AddJob(CCConfig.CheckRegisterIntervalSeconds, ServerNodeService.Instance.CheckRegisterJob);
            timer.Start();


            StardustClient.SetConfigCenterUrl("http://localhost:85");
        }
    }
}
